package com.taxi.driver.module.main.mine.help;

import com.qianxx.utils.RxUtil;
import com.taxi.driver.R;
import com.taxi.driver.common.BasePresenter;
import com.taxi.driver.data.user.UserRepository;
import com.taxi.driver.module.vo.FaqVO;

import javax.inject.Inject;

public class HelpCenterPresenter extends BasePresenter implements HelpCenterContract.Presenter {
    private UserRepository mUserRepository;
    private HelpCenterContract.View mView;
//   private AMapManager mapManager;
    @Inject
     HelpCenterPresenter(UserRepository userRepository, HelpCenterContract.View view) {
        mUserRepository = userRepository;
        mView = view;
//        this.mapManager=manager;
    }



    @Override
    public void reqFAQs() {
        mUserRepository.getProblems()
                .flatMapIterable(entities -> entities)
                .map(FaqVO::createFrom)
                .toList()
                .compose(RxUtil.applySchedulers())
                .doOnSubscribe(() -> mView.showLoadingView(false))
                .doAfterTerminate(() -> mView.hideLoadingView())
                .subscribe(vos -> {
                    mView.showFAQs(vos);
                }, ex -> {
                    showNetworkError(ex, R.string.network_error, mView, mUserRepository);
                });
    }

//    @Override
//    public void getCurrentCitys() {
////        Double lat = mapManager.getLastLocation() == null ? 0d : mapManager.getLastLocation().getLatitude();
////        Double lng = mapManager.getLastLocation() == null ? 0d : mapManager.getLastLocation().getLongitude();
////
////        KLog.e("=========lng===="+lng);
////        KLog.e("=========lat===="+lat);
////        LatLng latLng=new LatLng(lat,lng);
////        mSubscriptions.add(
////                mapManager.geocodeSearch(latLng).first().compose(RxUtil.applySchedulers())
////                        .subscribe(new Action1<RegeocodeAddress>() {
////                            @Override
////                            public void call(RegeocodeAddress regeocodeAddress) {
////                                KLog.e("=========CITY===="+regeocodeAddress.getCity());
////                            }
////                        }, new Action1<Throwable>() {
////                            @Override
////                            public void call(Throwable throwable) {
////                                KLog.e("=========Throwable===="+throwable.getMessage());
////                            }
////                        }));
////
////        LatLng  mCurrentLatLng = new LatLng(mapManager.getLastLocation().getLatitude(), mapManager.getLastLocation().getLongitude());
////        KLog.e("=====double====");
////        mapManager.geocodeSearch(mCurrentLatLng)
////                .compose(RxUtil.applySchedulers())
////                .subscribe(address -> {
////                    mView.getCurrentCity(address.getCity());
//////                    String destAddress = address.getPois().get(0).getTitle();
//////                    String destDetailAddress = address.getFormatAddress();
//////                    String destCity = address.getCity();
//////                    double destLng = mCurrentLatLng.longitude;
//////                    double destLat = mCurrentLatLng.latitude;
////                }, ex -> showNetworkError(ex, R.string.error, mView));
//
//    }
}
